package cn.wind.xboot.module.web.controller.cli;

import cn.wind.xboot.core.annotation.RestJsonController;
import cn.wind.xboot.core.res.ApiResult;
import cn.wind.xboot.logic.cli.dto.CliDto;
import cn.wind.xboot.logic.cli.entity.CliClient;
import cn.wind.xboot.logic.cli.service.ICliClientService;
import cn.wind.xboot.logic.cli.service.ICliInfoService;
import cn.wind.xboot.framework.domain.PageVo;
import cn.wind.xboot.framework.domain.SearchVo;
import cn.wind.xboot.framework.web.controller.BaseController;
import cn.wind.xboot.module.web.vo.cli.CliClientQueryVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.google.common.collect.Maps;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * <p>Title: CliClientController</p>
 * <p>Description: TODO</p>
 *
 * @author xukk
 * @version 1.0
 * @date 2018/9/3
 */
@Slf4j
@RestJsonController
@Api(value = "cli", tags = "用戶管理接口")
@RequestMapping("cli")
public class CliClientController extends BaseController<CliClient, Long> {
    @Autowired
    private ICliClientService cliClientService;
    @Autowired
    private ICliInfoService cliInfoService;
    @Override
    public IService getService() {
        return cliClientService;
    }

    @PreAuthorize("hasRole('client:client:view')")
    @GetMapping
    @ApiOperation(value = "多条件分页获取会员列表")
    public ApiResult get(CliClientQueryVo clientQueryVo, PageVo pageVo, SearchVo searchVo){
        Map<String,Object> map= Maps.newHashMap();
        map.putAll(beanMapper.map(clientQueryVo,Map.class));
        map.putAll(beanMapper.map(searchVo,Map.class));
        IPage<CliClient> page = cliClientService.findByCondition(pageVo.init(),map);
        return ApiResult.Custom().success().add(page);
    }



}
